package leetcode;

import java.util.*;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-12-11 22:30
 **/
public class LeetCode5934 {

    public int[] maxSubsequence(int[] nums, int k) {
        Integer[] index = new Integer[nums.length];
        for (int i = 0; i < index.length; i++) {
            index[i] = i;
        }
        Arrays.sort(index, (o, p) -> nums[p] - nums[o]);
        int[] result = new int[k];
        for (int i = 0; i < k; i++) {
            result[i] = index[i];
        }
        Arrays.sort(result);
        for (int i = 0; i < k; i++) {
            result[i] = nums[result[i]];
        }
        return result;
    }

    public static void main(String[] args) {
        LeetCode5934 code = new LeetCode5934();
        code.maxSubsequence(new int[]{63,-74,61,-17,-55,-59,-10,2,-60,-65}, 9);
    }
}
